package com.blockchain.console.servlets.content.banner;
import java.sql.Timestamp;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.blockchain.common.enums.AdvertisementStatus;
import com.blockchain.common.enums.SbType;
import com.blockchain.console.service.content.AdvertisementManage;
import com.blockchain.console.service.content.entity.AdvertisementRecord;
import com.blockchain.console.service.content.query.AdvertisementRecordQuery;
import com.blockchain.framework.http.servlet.annotation.Right;
import com.blockchain.framework.service.ServiceSession;
import com.blockchain.framework.service.query.Paging;
import com.blockchain.framework.service.query.PagingResult;
import com.blockchain.util.parser.EnumParser;
import com.blockchain.util.parser.IntegerParser;
@Right(id = "C_CONTENT_BANNER_SEARCH", isMenu=true, name = "Banner管理")
public class SearchBanner extends AbstractAdvertiseServlet {

	private static final long serialVersionUID = 1L;

	@Override
	protected void processGet(HttpServletRequest request,
			HttpServletResponse response, ServiceSession serviceSession)
			throws Throwable {
		processPost(request, response, serviceSession);
	}

	@Override
	protected void processPost(final HttpServletRequest request,
			final HttpServletResponse response,
			final ServiceSession serviceSession) throws Throwable {
		AdvertisementManage advertisementManage = serviceSession
				.getService(AdvertisementManage.class);
		PagingResult<AdvertisementRecord> result = advertisementManage.search(
				new AdvertisementRecordQuery() {
					
					@Override
					public Timestamp getUpdateTimeStart() {
						return null;
					}
					
					@Override
					public Timestamp getUpdateTimeEnd() {
						return null;
					}
					
					@Override
					public String getTitle() {
						return null;
					}
					
					@Override
					public AdvertisementStatus getStatus() {
						return EnumParser.parse(AdvertisementStatus.class,
								request.getParameter("status"));
					}
					
					@Override
					public SbType getSblx() {
						return EnumParser.parse(SbType.class,
								request.getParameter("sblx"));
					}
					
					@Override
					public String getPublisherName() {
						return null;
					}
					
					@Override
					public Timestamp getCreateTimeStart() {
						return null;
					}
					
					@Override
					public Timestamp getCreateTimeEnd() {
						return null;
					}
				}, new Paging() {
					@Override
					public int getSize() {
						return 10;
					}

					@Override
					public int getCurrentPage() {
						return IntegerParser.parse(request
								.getParameter(PAGING_CURRENT));
					}
				});
		request.setAttribute("result", result);
		forwardView(request, response, getClass());
	}

}
